﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Light.Framework
{
    /// <summary>
    /// 数据库SQL参数
    /// </summary>
    [Serializable]
    internal class DataParameter : IDataParameter
    {
        public DataParameter()
        {
        }

        public DataParameter(string parameterName, object value)
        {
            this.ParameterName = parameterName;
            this.Value = value;

            if (value is Enum)
            {
                value = (int)value;
                this.DbType = DbType.Int32;
            }
            else if (value is Boolean)
            {
                this.DbType = DbType.Boolean;
            }
            else if (value is DateTime)
            {
                this.DbType = DbType.DateTime;
            }
            else
            {
                this.DbType = DbType.String;
            }
        }


        public int Size
        {
            get;
            set;
        }

        public DbType DbType
        {
            get;
            set;
        }

        public ParameterDirection Direction
        {
            get;
            set;
        }

        public bool IsNullable
        {
            get { throw new NotImplementedException(); }
        }

        public string ParameterName
        {
            get;
            set;
        }

        public string SourceColumn
        {
            get;
            set;
        }

        public DataRowVersion SourceVersion
        {
            get;
            set;
        }

        public object Value
        {
            get;
            set;
        }
    }
}
